<?php
require_once('GenesisController.php');

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{



   protected function _initDoctype()
    {
    	$this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
    	
    }

   protected function _initMenu()
    {
        $view = $this->getResource('view');
        $nav = new Zend_Config_Xml(APPLICATION_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'navigation.xml', 'nav');
        $container = new Zend_Navigation($nav);
        $view->navigation()->setContainer($container);
    }
    

    protected function _initConfig() 
    {
        
    	$config = new Zend_Config_Ini(APPLICATION_PATH . DIRECTORY_SEPARATOR. 'configs'.DIRECTORY_SEPARATOR.'application.ini',APPLICATION_ENV);
    	Zend_Registry::set('application_config',$config);
    	$config = new Zend_Config_Ini(APPLICATION_PATH . DIRECTORY_SEPARATOR. 'configs'.DIRECTORY_SEPARATOR.'files.ini','default',array('allowModifications' => true));
    	Zend_Registry::set('files_config',$config);
    	    	
    } 
    
    protected function _initAutoload()
    {
        $params = array(
            'namespace' => 'Default',
            'basePath'  => APPLICATION_PATH
        );
    	$autoloader = new Zend_Application_Module_Autoloader($params);
		
        return $autoloader;
    }

    protected function _initAcl()
    {

     $acl = new Zend_Acl();

     $roleGuest = new Zend_Acl_Role('guest');
     $acl->addRole($roleGuest);
     $acl->addRole(new Zend_Acl_Role('member'), $roleGuest)
         ->addRole(new Zend_Acl_Role('editor'), 'member')
         ->addRole(new Zend_Acl_Role('developer'), 'editor')
         ->addRole(new Zend_Acl_Role('admin'));

     $acl->add(new Zend_Acl_Resource('component'))
         ->add(new Zend_Acl_Resource('component-plugin'))
         ->add(new Zend_Acl_Resource('config'))
         ->add(new Zend_Acl_Resource('help'))
         ->add(new Zend_Acl_Resource('document'))
         ->add(new Zend_Acl_Resource('index'))
         ->add(new Zend_Acl_Resource('user'))
         ->add(new Zend_Acl_Resource('admin'))
         ->add(new Zend_Acl_Resource('image'));


     $acl->deny('guest','user');
     $acl->allow('guest','index');
     $acl->allow('guest','user',array('login', 'register-process', 'register'));
     $acl->allow('guest','component-plugin','get-component');

     $acl->deny('member','component');
     $acl->deny('member','help');
     $acl->allow('member','user','logout');
     $acl->deny('member','document','manage-document-groups');
     $acl->deny('member','image','manage-galleries');

     $acl->allow('editor','document');
     $acl->allow('editor','image');
     $acl->allow('editor','component',array('list-component-usage','get-components-usage-list','set-component-usage-list'));
     $acl->allow('editor','component-plugin');
     $acl->allow('editor','admin');
     
     
     $acl->allow('developer','component');
     $acl->deny('developer','config');
     $acl->deny('developer','user');
     $acl->allow('developer','help');
     $acl->allow('developer','user','logout');

     $acl->allow('admin');

     
     Zend_Registry::set('acl',$acl);

    $view = $this->getResource('view');
    $view->navigation()->setDefaultAcl($acl);    

    }
   
}
